package com.harlan.viewbindingstudy;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.harlan.viewbindingstudy.databinding.ActivationPopBinding;


/**
 * 筛选的弹出框
 */
public class ActivationPopWindow extends PopupWindow {
    private final Activity context;
    private TextView  Confirm;
    public ActivationPopWindow(Activity context) {
        this.context = context;
        initPop();
    }
    public void show() {
        showAtLocation(context.getWindow().getDecorView().findViewById(android.R.id.content), Gravity.CENTER, 0, 0);
    }
    ActivationPopBinding binding;
    private void initPop() {
        binding = ActivationPopBinding.inflate(LayoutInflater.from(context));
        View popView = binding.getRoot();
        //   View popView = View.inflate(context,R.layout.activation_pop, null);//原来
        //设置view
        this.setContentView(popView);
        this.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
        this.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
        //设置PopupWindow的焦点
        this.setFocusable(true);
        //设置窗口以外的地方点击可关闭pop
        this.setOutsideTouchable(true);
        //设置背景透明
        this.setBackgroundDrawable(new ColorDrawable(0x33000000));
        Confirm = popView.findViewById(R.id.Confirm);
        Confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });

    }
}
